package com.ssy.lingxi.enhance.controller.process;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.enhance.constant.RoleTypeEnum;
import com.ssy.lingxi.enhance.model.dto.CommonIdDTO;
import com.ssy.lingxi.enhance.model.dto.DiscontinueDTO;
import com.ssy.lingxi.enhance.model.qo.ProduceNoticeOrderQO;
import com.ssy.lingxi.enhance.model.vo.OuterAndInnerVO;
import com.ssy.lingxi.enhance.model.vo.ProduceNoticeOrderDetailsVO;
import com.ssy.lingxi.enhance.model.vo.ProduceNoticeOrderListVO;
import com.ssy.lingxi.enhance.service.common.CommonService;
import com.ssy.lingxi.enhance.service.process.ProcessAllService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @menu 加工能力 - 确认生产通知单(加工企业) - 生产通知单查询
 * @author fhj
 * @version 2.0.0
 * @date 2020/10/20
 */
@Api(tags = "加工能力 - 确认生产通知单(加工企业) - 生产通知单查询")
@RestController
@RequestMapping("/enhance/process/all")
public class ProcessAllController extends BaseController {

    @Resource
    private ProcessAllService allService;
    @Resource
    private CommonService commonService;

    @ApiOperation(value = "外部状态/内部状态")
    @GetMapping(value = "/outerAndInner")
    public Wrapper<OuterAndInnerVO> outerAndInner() {
        return allService.outerAndInner();
    }

    @ApiOperation(value = "列表")
    @GetMapping(value = "/list")
    public Wrapper<PageData<ProduceNoticeOrderListVO>> list(@Valid ProduceNoticeOrderQO qo) {
        return allService.list(qo, getSysUser());
    }

    @ApiOperation(value = "详情")
    @GetMapping(value = "/details")
    public Wrapper<ProduceNoticeOrderDetailsVO> details(@Valid CommonIdDTO dto) {
        return commonService.details(dto.getId(), RoleTypeEnum.PROCESS.getCode(), getSysUser());
    }

    @ApiOperation(value = "中止")
    @PostMapping(value = "/discontinue")
    public Wrapper<Void> discontinue(@RequestBody @Valid DiscontinueDTO dto) {
        return allService.discontinue(dto, getSysUser());
    }
}
